// app.js
App({
  globalData: {
    isMusicPlay: false,
    songId: '',
    loopMode: 0, // 0-循环 1-随机 2-单曲
    userInfo: null,
    backgroundAudioManager: null,
    playList: [], // 播放列表
    currentIndex: -1, // 当前播放索引
    pendingSong: null // 待播放歌曲
  },

  onLaunch() {
    // 初始化音频管理器
    this.globalData.backgroundAudioManager = wx.getBackgroundAudioManager();
    
    // 监听音频事件
    this.globalData.backgroundAudioManager.onPlay(() => {
      this.globalData.isMusicPlay = true;
    });
    
    this.globalData.backgroundAudioManager.onPause(() => {
      this.globalData.isMusicPlay = false;
    });
    
    this.globalData.backgroundAudioManager.onStop(() => {
      this.globalData.isMusicPlay = false;
    });
  }
});